<template>
  <div>
    <el-form ref="dataForm" v-model="query" class="form" :rules="rules">
      <el-form-item prop="diffDistance" label="签收与实际地址差异距离:">
        <el-input v-model.number="query.diffDistance" oninput="value=value.replace(/^0|[^0-9]/g, '')" style="width: 100px;" size="mini" controls-position="right">
          <template slot="suffix">米</template>
        </el-input>
      </el-form-item>
      <el-form-item prop="ck_007_sys_setting_2_0">
        <el-checkbox v-model="query.ck_007_sys_setting_2_0">运气到家新建客户必须审核</el-checkbox>
      </el-form-item>
      <el-form-item prop="ck_007_sys_setting_2_2">
        <el-checkbox v-model="query.ck_007_sys_setting_2_2">关闭运气到家无订单配送</el-checkbox>
      </el-form-item>
      <el-form-item prop="ck_007_sys_setting_2_3">
        <el-checkbox v-model="query.ck_007_sys_setting_2_3">启用运气到家代客下单</el-checkbox>
      </el-form-item>
      <el-form-item prop="ck_007_sys_setting_sp4_23">
        <el-checkbox v-model="query.ck_007_sys_setting_sp4_23">启用月结、预充值客户强制签字</el-checkbox>
      </el-form-item>
      <el-divider />
      <!-- <el-form-item prop="days" label="运气到家待处理订单保存天数:">
        <el-input-number v-model="query.days" size="mini" controls-position="right" :min="1" :max="30" :precision="0" />
      </el-form-item> -->
      <el-form-item prop="scanLimitTime" label="重复扫描重瓶时间间隔">
        <el-input v-model="query.scanLimitTime" oninput="value=value.replace(/^0|[^0-9]/g, '')" size="mini" controls-position="right" style="width: 100px;">
          <template slot="suffix">分钟</template>
        </el-input>
      </el-form-item>
      <el-form-item prop="ck_007_sys_setting_2_8">
        <el-checkbox v-model="query.ck_007_sys_setting_2_8">按单配送扫瓶时重瓶扫描数必须与商品数一致</el-checkbox>
      </el-form-item>
      <el-form-item prop="ck_007_sys_setting_2_9">
        <el-checkbox v-model="query.ck_007_sys_setting_2_9">运气到家扫瓶时启用条码扫描</el-checkbox>
      </el-form-item>
      <el-form-item prop="ck_007_sys_setting_2_10">
        <el-checkbox v-model="query.ck_007_sys_setting_2_10">运气到家启用签收前打印</el-checkbox>
      </el-form-item>
      <el-form-item prop="ck_007_sys_setting_2_11">
        <el-checkbox v-model="query.ck_007_sys_setting_2_11">运气到家启用签收前空瓶数量校验</el-checkbox>
      </el-form-item>
      <el-form-item prop="ck_007_sys_setting_2_14">
        <el-checkbox v-model="query.ck_007_sys_setting_2_14">运气到家客户签收时需电子签名</el-checkbox>
      </el-form-item>
      <el-form-item prop="ck_007_sys_setting_2_15">
        <el-checkbox v-model="query.ck_007_sys_setting_2_15">运气到家扫瓶启用流程管控</el-checkbox>
      </el-form-item>
      <el-form-item prop="ck_007_sys_setting_2_17">
        <div style="color: #606266;">
          配送端订单签收允许修改
          <el-select v-model="query.orderSignUpdateFee" size="mini" style="width: 100px;" @click.native.prevent="()=>{}">
            <el-option label="无" :value="0" />
            <el-option label="实收金额" :value="1" />
            <el-option label="配送费" :value="2" />
          </el-select>
        </div>
      </el-form-item>
      <el-form-item prop="ck_007_sys_setting_2_25">
        <el-checkbox v-model="query.ck_007_sys_setting_2_25">是否显示配送业绩</el-checkbox>
      </el-form-item>
      <!-- <el-form-item prop="ck_007_sys_setting_3_0">
        <el-checkbox v-model="query.ck_007_sys_setting_3_0">运气到家支付签收页面独立显示</el-checkbox>
      </el-form-item>
      <el-form-item prop="ck_007_sys_setting_sp4_0">
        <el-checkbox v-model="query.ck_007_sys_setting_sp4_0">随订单安检匹配安检任务单</el-checkbox>
      </el-form-item> -->
      <el-form-item prop="ck_007_sys_setting_sp4_18">
        <el-checkbox v-model="query.ck_007_sys_setting_sp4_18">运气到家教客下单过滤50型</el-checkbox>
      </el-form-item>
      <el-form-item prop="ck_007_sys_setting_sp4_19">
        <el-checkbox v-model="query.ck_007_sys_setting_sp4_19">运气到家教客下单过滤15型</el-checkbox>
      </el-form-item>
      <el-form-item prop="ck_007_sys_setting_sp4_20">
        <el-checkbox v-model="query.ck_007_sys_setting_sp4_20">运气到家教客下单过滤5型</el-checkbox>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
  import { mapGetters } from 'vuex'

  export default {
    name: 'DistributionTab',
    data() {
      return {
        query: {
          // days: 30,
          ck_007_sys_setting_2_0: false,
          ck_007_sys_setting_2_2: false,
          ck_007_sys_setting_2_3: false,
          ck_007_sys_setting_2_8: false,
          ck_007_sys_setting_2_9: false,
          ck_007_sys_setting_2_10: false,
          ck_007_sys_setting_2_11: false,
          ck_007_sys_setting_2_14: false,
          ck_007_sys_setting_2_15: false,
          ck_007_sys_setting_2_17: false,
          ck_007_sys_setting_2_25: false,
          ck_007_sys_setting_3_0: false,
          ck_007_sys_setting_sp4_0: false,
          ck_007_sys_setting_sp4_18: false,
          ck_007_sys_setting_sp4_19: false,
          ck_007_sys_setting_sp4_20: false,
          ck_007_sys_setting_sp4_23: false,
          diffDistance: null,
          scanLimitTime: null,
          orderSignUpdateFee: 0
        },
        rules: {
          // days: [{ required: true, message: '请输入运气到家待处理订单保存天数', trigger: 'change' }]
        }
      }
    },
    computed: {
      ...mapGetters([
        'corpSettingData', 'userInfo'
      ])
    },
    created() {
      this.init()
    },
    methods: {
      init() {
        if (this.corpSettingData) {
          //  十六进制0x07  0000 0111
          // const preDays = (this.corpSettingData.sp2 >> 4 & 0x07) + 1
          // const newDays = this.corpSettingData.billMaxDate
          // if (preDays > newDays) {
          //   this.query.days = (this.corpSettingData.sp2 >> 4 & 0x07) + 1
          // } else {
          //   this.query.days = this.corpSettingData.billMaxDate
          // }
          // this.query.days = this.corpSettingData.userOrderDays + 1
          this.query.ck_007_sys_setting_2_0 = !!(this.corpSettingData.sp2 & 0x01)
          this.query.ck_007_sys_setting_2_2 = !!(this.corpSettingData.sp2 >> 2 & 0x01)
          this.query.ck_007_sys_setting_2_3 = !!(this.corpSettingData.sp2 >> 3 & 0x01)
          this.query.ck_007_sys_setting_2_8 = !!(this.corpSettingData.sp2 >> 8 & 0x01)
          this.query.ck_007_sys_setting_2_9 = !!(this.corpSettingData.sp2 >> 9 & 0x01)
          this.query.ck_007_sys_setting_2_10 = !!(this.corpSettingData.sp2 >> 10 & 0x01)
          this.query.ck_007_sys_setting_2_11 = !!(this.corpSettingData.sp2 >> 11 & 0x01)
          this.query.ck_007_sys_setting_2_14 = !!(this.corpSettingData.sp2 >> 14 & 0x01)
          this.query.ck_007_sys_setting_2_15 = !!(this.corpSettingData.sp2 >> 15 & 0x01)
          this.query.ck_007_sys_setting_2_17 = !!(this.corpSettingData.sp2 >> 17 & 0x01)
          this.query.ck_007_sys_setting_2_25 = !!(this.corpSettingData.sp2 >> 25 & 0x01)
          this.query.ck_007_sys_setting_3_0 = !!(this.corpSettingData.sp3 & 0x01)
          this.query.ck_007_sys_setting_sp4_0 = !!(this.corpSettingData.sp4 & 0x01)
          this.query.ck_007_sys_setting_sp4_18 = !!(this.corpSettingData.sp4 >> 18 & 0x01)
          this.query.ck_007_sys_setting_sp4_19 = !!(this.corpSettingData.sp4 >> 19 & 0x01)
          this.query.ck_007_sys_setting_sp4_20 = !!(this.corpSettingData.sp4 >> 20 & 0x01)
          this.query.ck_007_sys_setting_sp4_23 = !!(this.corpSettingData.sp4 >> 23 & 0x01)
          this.query.diffDistance = this.corpSettingData.diffDistance
          this.query.scanLimitTime = this.corpSettingData.scanLimitTime
          this.query.orderSignUpdateFee = this.corpSettingData.orderSignUpdateFee
        }
      }
    }
  }
</script>

<style lang="scss" scoped>
.form {
  .el-form-item {
    margin-bottom: 0;
  }
}
</style>
